/**
 * 定义PLC点位配置模块
 */
(function(window, angular, undefined){
    var module = angular.module('water.apps.sw.bdPlcControl.bdPlcControlManager', ['water.entity.bdPlcControl',
        'water.entity.protocol']);

    module.controller('bdPlcControlManagerController',function($scope,$bdPlcControlService){

        $scope.deviceList;

        /**
         * 获取设备信息
         */
        $scope.getDeviceInfo = function(){
            $bdPlcControlService.getDeviceInfo().then(function(data){
                $scope.deviceList = data;
            });
        }

        /**
         * 获取系统信息
         */
        $scope.getSystemInfo = function(){
            $bdPlcControlService.getSystemInfo().then(function(data){
                $scope.systemInfo = data;
            });
        }

        /**
         * 设备详情点击事件
         */
        $scope.onDeviceDetailClick = function(deviceInfo){
            var data = {};
            data.TITLE = "DEVICE";
            data.TITLE_SHOW = deviceInfo.DEVICE_NAME + "设备状态";
            data.DEVICE_ID = deviceInfo.ID;
            $scope.$broadcast('plcDataChanged', data);
            $scope.detailDialog.open();
        }

        /**
         * 系统详情点击事件
         */
        $scope.onSystemDetailClick = function(){
            var data = {};
            data.TITLE = "SYSTEM";
            data.TITLE_SHOW = "系统运行状态";
            $scope.$broadcast('plcDataChanged', data);
            $scope.detailDialog.open();
        }

        $scope._init = function(){
            $scope.getDeviceInfo();
            $scope.getSystemInfo();
        }

        $scope._init();
    });

}(window, angular));


